package cn.thr.ymcc.quartz;

import cn.thr.ymcc.service.IKillCourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class Publish2RedisJob {

    @Autowired
    private IKillCourseService killCourseService;

    /**
     * 由于SpringBoot中已经整合了quartz定时任务
     * 只需要在启动类上添加@EnableScheduling
     * 然后编写一个bean的类，写一个普通方法加上@Scheduled注解，通过cron表达式指定定时任务执行频率
     * cron表达式在线生成器 http://www.pppet.net/
     */
    @Scheduled(cron = "0/10 * * * * *")
    public void Publish2RedisJob(){
        System.out.println("定时任务执行了,....");
        killCourseService.publish2Redis();
    }
}
